package handler

import (
	"blog2/database"
	"strconv"

	"github.com/gin-gonic/gin"
)

func AddBlogLikeToBlog(c *gin.Context) {
	id := c.Param("id")
	blogId, err := strconv.Atoi(id)
	if err != nil {
		c.JSON(200, gin.H{"msg": "invalid blog id", "code": 400})
		return
	}
	database.AddBlogCountToBlog(blogId, database.FIELD_BLOG_LIKE_COUNT)
}

func AddBlogFavoriteToBlog(c *gin.Context) {
	id := c.Param("id")
	blogId, err := strconv.Atoi(id)
	if err != nil {
		c.JSON(200, gin.H{"msg": "invalid blog id", "code": 400})
		return
	}
	database.AddBlogCountToBlog(blogId, database.FIELD_BLOG_FAVORITE_COUNT)
}
